#!/bin/bash
set -x
set -o pipefail

### --start_docs
## Execute repoclosure w/ options
## ==============================

## * run repoclosure
## ::

EXIT_CODE=0

{% for repo_name in yum_repos.stdout_lines %}

echo "*********************** repo: {{ repo_name }} *****************"
{% if repo_name in repoclosure_exclude_repos %}

  echo "skipping,  {{ repo_name }} is in var repoclosure_exclude_repos"

{% else %}

  dnf repoclosure --newest --check {{ repo_name }} --disablerepo '*' \
   {{ repoclosure_include_repos|join(' ') }} \
   --excludepkgs {{ repoclosure_exclude_pkgs|join(',') }} \
   --disablerepo 'delorean-current'
  if [ "$?" -ne 0 ]; then
    EXIT_CODE=1
  fi

{% endif %}
{% endfor %}

exit $EXIT_CODE
### --stop_docs
